package uk.co.richardwkirk.parkrun.android;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebView;

public class ParkrunWebDisplay extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Set the athlete display as the activity layout
		setContentView(R.layout.parkrun_web_display);

		// Get the parkrun webpage address from the intent
		Intent intent = getIntent();
		String url = intent.getStringExtra(IntentExtras.EXTRA_PARKRUN_WEBPAGE_URL);
		String title = intent.getStringExtra(IntentExtras.EXTRA_PARKRUN_WEBPAGE_TITLE);
		
		this.setTitle(title);
		
    	// Show the athlete summary page in the web view
		WebView webView = (WebView)findViewById(R.id.parkrun_webview);
		webView.loadUrl(url);
			
		// Show the Up button in the action bar.
		setupActionBar();
	}
	
	/**
	 * Set up the {@link android.app.ActionBar}, if the API is available.
	 */
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void setupActionBar() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			getActionBar().setDisplayHomeAsUpEnabled(true);
		}
	}

}
